| Conditions | 1 |
| Paths | 1 |
| Total Lines | 100 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | /* |
||
| 24 | module.exports = function(grunt) { |
||
| 25 | 'use strict'; |
||
| 26 | |||
| 27 | grunt.loadNpmTasks('grunt-contrib-concat'); |
||
| 28 | grunt.loadNpmTasks('grunt-contrib-watch'); |
||
| 29 | grunt.loadNpmTasks('grunt-contrib-jshint'); |
||
| 30 | grunt.loadNpmTasks('grunt-wrap'); |
||
| 31 | grunt.loadNpmTasks('grunt-karma'); |
||
| 32 | grunt.loadNpmTasks('grunt-phpunit'); |
||
| 33 | |||
| 34 | grunt.initConfig({ |
||
| 35 | |||
| 36 | meta: { |
||
| 37 | pkg: grunt.file.readJSON('package.json'), |
||
| 38 | version: '<%= meta.pkg.version %>', |
||
| 39 | configJS: 'config/', |
||
| 40 | buildJS: [ |
||
| 41 | 'app/**/*.js', |
||
| 42 | 'controller/**/*.js', |
||
| 43 | 'filters/**/*.js', |
||
| 44 | 'directive/**/*.js', |
||
| 45 | 'service/**/*.js' |
||
| 46 | ], |
||
| 47 | productionJS: 'public/', |
||
| 48 | testsJS: '../tests/js/' |
||
| 49 | }, |
||
| 50 | |||
| 51 | concat: { |
||
| 52 | options: { |
||
| 53 | stripBanners: true |
||
| 54 | }, |
||
| 55 | dist: { |
||
| 56 | src: ['<%= meta.buildJS %>'], |
||
| 57 | dest: '<%= meta.productionJS %>app.js' |
||
| 58 | } |
||
| 59 | }, |
||
| 60 | |||
| 61 | wrap: { |
||
| 62 | app: { |
||
| 63 | src: ['<%= meta.productionJS %>app.js'], |
||
| 64 | dest: '<%= meta.productionJS %>app.js', |
||
| 65 | option: { |
||
| 66 | wrapper: [ |
||
| 67 | '(function(angular, $, oc_requesttoken, undefined){\n\n\'use strict\';\n\n', |
||
| 68 | '\n})(angular, jQuery, oc_requesttoken);' |
||
| 69 | ] |
||
| 70 | } |
||
| 71 | } |
||
| 72 | }, |
||
| 73 | |||
| 74 | jshint: { |
||
| 75 | files: [ |
||
| 76 | 'Gruntfile.js', |
||
| 77 | '<%= meta.buildJS %>**/*.js', |
||
| 78 | '<%= meta.testsJS %>**/*.js' |
||
| 79 | ], |
||
| 80 | options: { |
||
| 81 | jshintrc: '.jshintrc', |
||
| 82 | reporter: require('jshint-stylish') |
||
| 83 | } |
||
| 84 | }, |
||
| 85 | |||
| 86 | watch: { |
||
| 87 | concat: { |
||
| 88 | files: ['<%=meta.buildJS%>'], |
||
| 89 | options: { |
||
| 90 | livereload: true |
||
| 91 | }, |
||
| 92 | tasks: ['build'] |
||
| 93 | } |
||
| 94 | }, |
||
| 95 | |||
| 96 | phpunit: { |
||
| 97 | classes: { |
||
| 98 | dir: '../tests/unit' |
||
| 99 | }, |
||
| 100 | options: { |
||
| 101 | bootstrap: '../tests/bootstrap.php', |
||
| 102 | colors: true |
||
| 103 | } |
||
| 104 | }, |
||
| 105 | |||
| 106 | karma: { |
||
| 107 | unit: { |
||
| 108 | configFile: '<%= meta.testsJS %>config/karma.js' |
||
| 109 | }, |
||
| 110 | continuous: { |
||
| 111 | configFile: '<%= meta.testsJS %>config/karma.js', |
||
| 112 | browsers: ['Firefox'], |
||
| 113 | singleRun: true, |
||
| 114 | reporters: ['progress'] |
||
| 115 | } |
||
| 116 | }, |
||
| 117 | }); |
||
| 118 | |||
| 119 | // make tasks available under simpler commands |
||
| 120 | grunt.registerTask('build', ['jshint', 'concat', 'wrap']); |
||
| 121 | grunt.registerTask('js-unit', ['karma:continuous']); |
||
| 122 | |||
| 123 | }; |
||
| 124 |